package com.ruoyi.camp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.camp.domain.CCampFacility;
import com.ruoyi.camp.service.ICCampFacilityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * campFacilityController
 * 
 * @author ruoyi
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/camp/campFacility")
public class CCampFacilityController extends BaseController
{
    @Autowired
    private ICCampFacilityService cCampFacilityService;

    /**
     * 查询campFacility列表
     */
//    @PreAuthorize("@ss.hasPermi('camp:campFacility:list')")
    @GetMapping("/list")
    public TableDataInfo list(CCampFacility cCampFacility)
    {
        startPage();
        List<CCampFacility> list = cCampFacilityService.selectCCampFacilityList(cCampFacility);
        return getDataTable(list);
    }

    /**
     * 导出campFacility列表
     */
    @PreAuthorize("@ss.hasPermi('camp:campFacility:export')")
    @Log(title = "campFacility", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CCampFacility cCampFacility)
    {
        List<CCampFacility> list = cCampFacilityService.selectCCampFacilityList(cCampFacility);
        ExcelUtil<CCampFacility> util = new ExcelUtil<CCampFacility>(CCampFacility.class);
        util.exportExcel(response, list, "campFacility数据");
    }

    /**
     * 获取campFacility详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:campFacility:query')")
    @GetMapping(value = "/{cfId}")
    public AjaxResult getInfo(@PathVariable("cfId") String cfId)
    {
        return success(cCampFacilityService.selectCCampFacilityByCfId(cfId));
    }

    /**
     * 新增campFacility
     */
    @PreAuthorize("@ss.hasPermi('camp:campFacility:add')")
    @Log(title = "campFacility", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CCampFacility cCampFacility)
    {
        return toAjax(cCampFacilityService.insertCCampFacility(cCampFacility));
    }

    /**
     * 修改campFacility
     */
    @PreAuthorize("@ss.hasPermi('camp:campFacility:edit')")
    @Log(title = "campFacility", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CCampFacility cCampFacility)
    {
        return toAjax(cCampFacilityService.updateCCampFacility(cCampFacility));
    }

    /**
     * 删除campFacility
     */
    @PreAuthorize("@ss.hasPermi('camp:campFacility:remove')")
    @Log(title = "campFacility", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cfIds}")
    public AjaxResult remove(@PathVariable String[] cfIds)
    {
        return toAjax(cCampFacilityService.deleteCCampFacilityByCfIds(cfIds));
    }
}
